package com.ticket.sass.common.entity.tenant;

import com.baomidou.mybatisplus.annotation.*;
import com.ticket.sass.common.entity.tenant.enums.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author ywb
 * @since 2024-03-07
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("orders")
@ApiModel(value = "OrdersEntity对象", description = "")
public class OrderEntity implements Serializable {
    @ApiModelProperty(value = "订单ID")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "订单号")
    private String orderNo;

    @ApiModelProperty(value = "外部订单号")
    private String externalOrderNo;

    @ApiModelProperty(value = "原价")
    private BigDecimal originalPrice;

    @ApiModelProperty(value = "支付价格")
    private BigDecimal payPrice;

    @ApiModelProperty(value = "支付类型：1 微信，2 支付宝，3 会员卡")
    private OrderPayType payType;

    @ApiModelProperty(value = "支付状态 5 已退款")
    private OrderPayStatus payStatus;

    @ApiModelProperty(value = "支付时间")
    private LocalDateTime payTime;

    @ApiModelProperty(value = "是否使用优惠券")
    private Boolean useCoupon;

    @ApiModelProperty(value = "订单类型 1 出票 2 卖品 3会员")
    private OrderType type;

    @ApiModelProperty(value = "订单渠道")
    private OrderChannel channel;

    @ApiModelProperty(value = "订单状态")
    private OrderStatus status;

    @ApiModelProperty(value = "用户ID")
    private Long userId;

    @ApiModelProperty(value = "混合下单记录ID")
    private Long orderMixedId;

    @ApiModelProperty(value = "影院ID")
    private Long cinemaId;

    @ApiModelProperty(value = "租户ID")
    private Long tenantId;

    @ApiModelProperty(value = "退款备注")
    private String refundRemark;

    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    public LocalDateTime createdAt;

    @ApiModelProperty(value = "更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    public LocalDateTime updatedAt;

    @TableField(select = false)
    @ApiModelProperty(value = "删除时间")
    @TableLogic(value = "null", delval = "now()")
    public LocalDateTime deletedAt;

    @TableField(exist = false)
    private BigDecimal sumPayPrice;

    @TableField(exist = false)
    private BigDecimal wxSumPayPrice;

    @TableField(exist = false)
    private BigDecimal memberSumPayPrice;

    @TableField(exist = false)
    private Integer totalRecords;

    @TableField(exist = false)
    private OrderTicketEntity orderTicket;

    @TableField(exist = false)
    private OrderCommodityEntity orderCommodity;

    @TableField(exist = false)
    private OrderCardRechargeEntity orderCardRecharge;

    @TableField(exist = false)
    private List<OrderCouponMapEntity> orderCouponMapList;

    @TableField(exist = false)
    private OrderTicketLaterPayEntity orderTicketLaterPay;

    @TableField(exist = false)
    private CinemaEntity cinema;

    @TableField(exist = false)
    private UserEntity user;

    @TableField(exist = false)
    private OrderGroupPurchaseEntity orderGroupPurchase;

    public OrderGroupPurchaseEntity getOrderGroupPurchase() {
        return orderGroupPurchase;
    }

    public void setOrderGroupPurchase(OrderGroupPurchaseEntity orderGroupPurchase) {
        this.orderGroupPurchase = orderGroupPurchase;
    }


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public String getExternalOrderNo() {
        return externalOrderNo;
    }

    public void setExternalOrderNo(String externalOrderNo) {
        this.externalOrderNo = externalOrderNo;
    }

    public BigDecimal getOriginalPrice() {
        return originalPrice;
    }

    public void setOriginalPrice(BigDecimal originalPrice) {
        this.originalPrice = originalPrice;
    }

    public BigDecimal getPayPrice() {
        return payPrice;
    }

    public void setPayPrice(BigDecimal payPrice) {
        this.payPrice = payPrice;
    }

    public OrderPayType getPayType() {
        return payType;
    }

    public void setPayType(OrderPayType payType) {
        this.payType = payType;
    }

    public OrderPayStatus getPayStatus() {
        return payStatus;
    }

    public void setPayStatus(OrderPayStatus payStatus) {
        this.payStatus = payStatus;
    }

    public LocalDateTime getPayTime() {
        return payTime;
    }

    public void setPayTime(LocalDateTime payTime) {
        this.payTime = payTime;
    }

    public Boolean getUseCoupon() {
        return useCoupon;
    }

    public void setUseCoupon(Boolean useCoupon) {
        this.useCoupon = useCoupon;
    }

    public OrderType getType() {
        return type;
    }

    public void setType(OrderType type) {
        this.type = type;
    }

    public OrderChannel getChannel() {
        return channel;
    }

    public void setChannel(OrderChannel channel) {
        this.channel = channel;
    }

    public OrderStatus getStatus() {
        return status;
    }

    public void setStatus(OrderStatus status) {
        this.status = status;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Long getOrderMixedId() {
        return orderMixedId;
    }

    public void setOrderMixedId(Long orderMixedId) {
        this.orderMixedId = orderMixedId;
    }

    public Long getCinemaId() {
        return cinemaId;
    }

    public void setCinemaId(Long cinemaId) {
        this.cinemaId = cinemaId;
    }

    public Long getTenantId() {
        return tenantId;
    }

    public void setTenantId(Long tenantId) {
        this.tenantId = tenantId;
    }

    public LocalDateTime getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }

    public LocalDateTime getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(LocalDateTime updatedAt) {
        this.updatedAt = updatedAt;
    }

    public LocalDateTime getDeletedAt() {
        return deletedAt;
    }

    public void setDeletedAt(LocalDateTime deletedAt) {
        this.deletedAt = deletedAt;
    }

    public BigDecimal getSumPayPrice() {
        return sumPayPrice;
    }

    public void setSumPayPrice(BigDecimal sumPayPrice) {
        this.sumPayPrice = sumPayPrice;
    }

    public OrderTicketEntity getOrderTicket() {
        return orderTicket;
    }

    public void setOrderTicket(OrderTicketEntity orderTicket) {
        this.orderTicket = orderTicket;
    }

    public OrderCommodityEntity getOrderCommodity() {
        return orderCommodity;
    }

    public void setOrderCommodity(OrderCommodityEntity orderCommodity) {
        this.orderCommodity = orderCommodity;
    }

    public OrderCardRechargeEntity getOrderCardRecharge() {
        return orderCardRecharge;
    }

    public void setOrderCardRecharge(OrderCardRechargeEntity orderCardRecharge) {
        this.orderCardRecharge = orderCardRecharge;
    }

    public List<OrderCouponMapEntity> getOrderCouponMapList() {
        return orderCouponMapList;
    }

    public void setOrderCouponMapList(List<OrderCouponMapEntity> orderCouponMapList) {
        this.orderCouponMapList = orderCouponMapList;
    }

    public OrderTicketLaterPayEntity getOrderTicketLaterPay() {
        return orderTicketLaterPay;
    }

    public void setOrderTicketLaterPay(OrderTicketLaterPayEntity orderTicketLaterPay) {
        this.orderTicketLaterPay = orderTicketLaterPay;
    }

    public CinemaEntity getCinema() {
        return cinema;
    }

    public void setCinema(CinemaEntity cinema) {
        this.cinema = cinema;
    }

    public UserEntity getUser() {
        return user;
    }

    public void setUser(UserEntity user) {
        this.user = user;
    }

    public String getRefundRemark() {
        return refundRemark;
    }

    public void setRefundRemark(String refundRemark) {
        this.refundRemark = refundRemark;
    }

    public Boolean isPaid() {
        return payStatus == OrderPayStatus.PAID && status == OrderStatus.NORMAL;
    }
}
